package com.cloud.pole.user.service.account.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cloud.pole.common.util.jwt.IJWTInfo;
import com.cloud.pole.common.util.jwt.JwtTokenUtil;
import com.cloud.pole.user.biz.account.UserAccountDetailBiz;
import com.cloud.pole.user.model.vo.account.UserAccountDetailVo;
import com.cloud.pole.user.service.account.UserAccountDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import lombok.extern.slf4j.Slf4j;

/*
*2019年1月30日
*cloud-user
*author:frank-chen
*/
@Service
@Slf4j
public class UserAccountDetailServiceImpl implements UserAccountDetailService {
	
	@Autowired
    private UserAccountDetailBiz userAccountDetailBiz;

	@Override
	public PageInfo<UserAccountDetailVo> getAccountDetailList(String token, Long accountId, Integer pageNum, Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		IJWTInfo jwtInfo = JwtTokenUtil.getInfoFromToken(token);
		Long userId = Long.parseLong(jwtInfo.getId());
		PageHelper.startPage(pageNum, pageSize); 
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userId", userId);
		map.put("accountId", accountId);
    	List<UserAccountDetailVo> list = userAccountDetailBiz.selectPageAccountDetailListByMap(map);
    	PageInfo<UserAccountDetailVo> page = new PageInfo<UserAccountDetailVo>(list);
    	return page;
	}
}
